home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / tex-k / tex-eplain-archive / 000009_kb@cs.umb.edu_Sat Apr 16 12:21:34 1994.msg < prev    next >
Internet Message Format  |  1995-01-08  |  21KB

  1. Received: from terminus.cs.umb.edu by cs.umb.edu with SMTP id AA25130
  2.   (5.65c/IDA-1.4.4 for <tex-eplain-exp@cs.umb.edu>); Sat, 16 Apr 1994 16:21:35 -0400
  3. Received: by terminus.cs.umb.edu id AA29542
  4.   (5.65c/IDA-1.4.4 for tex-eplain); Sat, 16 Apr 1994 16:21:34 -0400
  5. Date: Sat, 16 Apr 1994 16:21:34 -0400
  6. From: "K. Berry" <kb@cs.umb.edu>
  7. Message-Id: <199404162021.AA29542@terminus.cs.umb.edu>
  8. To: tex-eplain@cs.umb.edu
  9. Subject: indexing
  10.  
  11. Here's the indexing support I've been working on, if anyone is brave
  12. enough to test it. The shar file has two files -- the tex source and the
  13. beginnings of the documentation.
  14.  
  15. Comments are welcome.
  16.  
  17. #!/bin/sh
  18. #    This is a shell archive.
  19. #    Run the file through sh to extract its contents.
  20. # shar:    Shell Archiver
  21. #    Run the following text with /bin/sh to create:
  22. #    eidx.tex
  23. #    idx.texi
  24. # This archive created: Sat Apr 16 16:19:33 1994
  25. # By:     ()
  26. cat << \SHAR_EOF > eidx.tex
  27. \input eplain
  28. \catcode`@ = 11
  29.  
  30. % The index(es).
  31. % \defineindex{PREFIX} defines an index with ``prefix'' PREFIX.  The
  32. % prefix is used to construct the output filename and the various
  33. % commands.  We just define all the index commands for this index to
  34. % call the general commands with PREFIX.
  35. %
  36. \let\extraidxcmdsuffixes = \empty
  37. %
  38. \outer\def\defineindex#1{%
  39.   \def\@idxprefix{#1}%
  40.   %
  41.   % Define the indexing commands for this prefix. 
  42.   \for\@idxcmd:=,marked,submarked,name%
  43.                 \extraidxcmdsuffixes\do
  44.   {%
  45.     \@defineindexcmd\@idxcmd
  46.   }%
  47.   %
  48.   % Allocate a stream for the output.
  49.   \ece\innernewwrite{@#1indexfile}%
  50.   %
  51.   % And a conditional to test whether we've opened the file.
  52.   \ece\innernewif{if@#1indexfileopened}%
  53. }%
  54. %
  55. %
  56. % \@defineindexcmd{SUFFIX} defines both silent and non-silent index
  57. % command for prefix \@idxprefix with suffix SUFFIX.  That is, we define
  58. % both `\@idxprefix dxSUFFIX' and `\s\@idxprefix dxSUFFIX' to call the
  59. % corresponding generic command with \@idxprefix.  \silentindexentry is
  60. % used to decide whether we should ignore following spaces.
  61. \newif\ifsilentindexentry
  62. %
  63. \def\@defineindexcmd#1{%
  64.   \@defineoneindexcmd{s}{#1}\silentindexentrytrue
  65.   \@defineoneindexcmd{}{#1}\silentindexentryfalse
  66. }%
  67. %
  68. %
  69. % \@defineoneindexcmd{PREFIX}{SUFFIX}{PRECALL} does just one silent or
  70. % non-silent commands.  We define the command `\@@PREFIXidxSUFFIX' to do
  71. % PRECALL, then define \@idxprefix, then call \@idxgetrange with an
  72. % argument of `\@@{,s}idxSUFFIX'.  (So far every indexing command 
  73. % should allow a range.  If not, you could redefine `\@@{,s}idxSUFFIX'
  74. % after this macro is called.)
  75. \def\@defineoneindexcmd#1#2#3{%
  76.   \toks@ = {#3}%
  77.   \edef\temp{%
  78.     \def
  79.       % We have to restrict expansion because the generic (\@@...)
  80.       % commands will be defined after the first call to \defineindex.
  81.       % Not expanding the user (\idx...) commands is unnecessary unless
  82.       % the user has defined some new commands, but may as well be cautious.
  83.       \expandonce\csname#1\@idxprefix dx#2\endcsname % e.g., \idx or \sidxname.
  84.       {\def\noexpand\@idxprefix{\@idxprefix}% define \@idxprefix
  85.        % call, e.g., \@@idx or \@@sidxname:
  86.        \expandonce\csname @@#1idx#2\endcsname
  87.       }%
  88.     \def
  89.       \expandonce\csname @@#1idx#2\endcsname{% e.g., \@@idx
  90.         % First do PRECALL.
  91.         \the\toks@
  92.         % Then call \@idxgetrange with, e.g., \@idx or \@sidxname as its arg.
  93.         \noexpand\@idxgetrange\expandonce\csname @#1idx#2\endcsname
  94.       }%
  95.   }%
  96.   \temp
  97. }%
  98. %
  99. %
  100. % \@idxwrite{TERM}{PAGENO} writes a general index entry for TERM on page
  101. % PAGENO to the index file `\@idxprefix indexfile'.  We open the stream
  102. % as `\indexfilebasename.\@idxprefix dx' if it isn't already open.
  103. %
  104. \let\indexfilebasename = \jobname
  105. %
  106. \def\@idxwrite#1#2{%
  107.   % Be sure the file is opened.
  108.   \csname if@\@idxprefix indexfileopened\endcsname \else
  109.     \expandafter\immediate\openout\csname @\@idxprefix indexfile\endcsname =
  110.       \indexfilebasename.\@idxprefix dx
  111.     \expandafter\global\csname @\@idxprefix indexfileopenedtrue\endcsname
  112.   \fi
  113.   %
  114.   % Save the index term.
  115.   \def\temp{#1}%
  116.   %
  117.   % Write the index term and page number.
  118.   \edef\@wr{%
  119.     \expandafter\write\csname @\@idxprefix indexfile\endcsname{%
  120.       \string\indexentry
  121.       {\sanitize\temp}%
  122.       {\noexpand#2}%
  123.     }%
  124.   }%
  125.   \@wr
  126.   % 
  127.   % Marginalize the index term, if desired.
  128.   \ifindexproofing \insert\@indexproof{\indexproofterm{#1}}\fi
  129.   %
  130.   % We just appended at least one non-discardable item (namely, the
  131.   % whatsit from the \write) to the current list.  So in case glue comes
  132.   % next (not unlikely), be sure we don't inadvertently make that glue a
  133.   % valid breakpoint, if it wouldn't have been without us.
  134.   \hookrun{afterindexterm}%
  135.   %
  136.   % This is the end of the index entry processing.  If this was a silent
  137.   % entry, ignore following spaces.
  138.   \ifsilentindexentry \expandafter\ignorespaces\fi
  139. }%
  140. %
  141. %
  142. % If this conditional is true, we output the index terms on the page
  143. % where they occur.
  144. \newif\ifindexproofing
  145. %
  146. % We need a new insertion class to collect the proofed terms.
  147. \newinsert\@indexproof
  148. \dimen\@indexproof = \maxdimen                  % No limit on number of terms.
  149. \count\@indexproof = 0  \skip\@indexproof = 0pt % They take up no space.
  150. %
  151. % This actually typesets the proofed term.  We don't go to any lengths
  152. % to provide nice-looking output; since the term might have all kinds of
  153. % weird characters in it, we just dump it in the smallest standard
  154. % Computer Modern typewriter font.
  155. % We put the term in an \hbox, even though that might make the output
  156. % run off the page, since we don't really need to see all of it, and
  157. % I think it's better to opt for simplicity -- one term per line.
  158. \font\indexprooffont = cmtt8
  159. \def\indexproofterm#1{\hbox{\strut \indexprooffont #1}}%
  160. %
  161. %
  162. % If \output doesn't use \makeheadline, or redefines it, it's up to the
  163. % new \output to call \indexproofunbox.
  164. \let\@plainmakeheadline = \makeheadline
  165. \def\makeheadline{%
  166.   \ifvoid\@indexproof\else \indexsetmargins \indexproofunbox \fi
  167.   \@plainmakeheadline
  168. }%
  169. %
  170. % We want to put the proof index terms in the margin, outside the
  171. % printed area. So if \outsidemargin (for odd pages) and \insidemargin
  172. % (for even pages) are undefined, we define them (both) to be the default
  173. % TeX margin -- one inch + \hoffset.
  174. \def\indexsetmargins{%
  175.   \ifx\undefined\outsidemargin
  176.     \dimen@ = 1in
  177.     \advance\dimen@ by \hoffset
  178.     \edef\outsidemargin{\the\dimen@}%
  179.     \let\insidemargin = \outsidemargin
  180.   \fi
  181. }%
  182. %
  183. % We always put the terms in the right-hand margin, so long terms run
  184. % off the page, instead of into the text.
  185. \def\indexproofunbox{%
  186.   \rlap{%
  187.     \kern\hsize
  188.     \ifodd\pageno \kern\outsidemargin \else \kern\insidemargin \fi
  189.     \vbox to 0pt{\unvbox\@indexproof\vss}%
  190.   }%
  191. }%
  192. %
  193. %
  194. % \@idxgetrange\CS parses an optional argument which, if present, should
  195. % be either `begin' or `end', marking the beginning or ending of a range
  196. % for the index entry.  If we find this, we set the appropriate one of
  197. % \@idxrangestr.  Then we call \CS.
  198. % If the optional argument is `see' or `seealso' we read another
  199. % argument, namely, the entry to see.
  200. \def\idxrangebeginword{begin}%
  201. \def\idxbeginrangemark{(}% the corresponding magic char to go in the idx file
  202. %
  203. \def\idxrangeendword{end}%
  204. \def\idxendrangemark{)}%
  205. %
  206. \def\idxseecmdword{see}%
  207. \def\idxseealsocmdword{seealso}%
  208. \newif\if@idxsee
  209. \let\@idxseenterm = \relax
  210. %
  211. \def\idxpagemarkupcmdword{pagemarkup}%
  212. \let\@idxpagemarkup = \relax
  213. %
  214. \def\@idxgetrange#1{%
  215.   \let\@idxrangestr = \empty
  216.   \let\@afteridxgetrange = #1%
  217.   \@getoptionalarg\@finidxgetopt
  218. }%
  219. \def\@finidxgetopt{%
  220.   \for\@idxarg:=\@optionalarg\do{%
  221.     % These are ordered by my guess at frequency of use.
  222.     \expandafter\@idxcheckpagemarkup\@idxarg=,%
  223.     %
  224.     \ifx\@idxarg\idxrangebeginword
  225.       \def\@idxrangestr{\idxencapoperator\idxbeginrangemark}%
  226.     \else
  227.       \ifx\@idxarg\idxrangeendword
  228.         \def\@idxrangestr{\idxencapoperator\idxendrangemark}%
  229.       \else
  230.         \ifx\@idxarg\idxseecmdword
  231.           \def\@idxpagemarkup{indexsee}%
  232.           \@idxseetrue
  233.         \else
  234.           \ifx\@idxarg\idxseealsocmdword
  235.             \def\@idxpagemarkup{indexseealso}%
  236.             \@idxseetrue
  237.           \else
  238.              \ifx\@idxpagemarkup\relax
  239.                \errmessage{Unrecognized index option `\@idxarg'}%
  240.              \fi
  241.           \fi
  242.         \fi
  243.       \fi
  244.     \fi
  245.   }%
  246.   \@afteridxgetrange
  247. }%
  248. %
  249. %
  250. % Check for a command of the form `pagemarkup=\cmd', and if found, set
  251. % \@idxpagemarkup to `cmd'.
  252. \def\@idxcheckpagemarkup#1=#2,{%
  253.   \def\temp{#1}%
  254.   \ifx\temp\idxpagemarkupcmdword
  255.     \if ,#2, % If #2 is empty, complain.
  256.       \errmessage{Missing markup command to `pagemarkup'}%
  257.     \else
  258.       % Remove a trailing =.
  259.       \def\temp##1={##1}%
  260.       \edef\@idxpagemarkup{\temp\string#2}%
  261.     \fi
  262.   \fi
  263. }%
  264. %
  265. %
  266. % \@idxtokscollect uses \@idxmaintoks as the token list for the main
  267. % part of an index entry and \@idxsubtoks for the subpart.  Then it
  268. % calls \@idxwrite.
  269. \def\idxsubentryseparator{!}%
  270. \def\idxencapoperator{|}%
  271. \def\idxmaxpagenum{99999}%
  272. %
  273. \newtoks\@idxmaintoks
  274. \newtoks\@idxsubtoks
  275. %
  276. \def\@idxtokscollect{%
  277.   % Remember the subentry.
  278.   \edef\temp{\the\@idxsubtoks}%
  279.   %
  280.   % We want to expand the conditions, but not the terms.  The index
  281.   % entry starts simply with \@idxmaintoks and \@idxsubtoks.
  282.   \edef\@indexentry{%
  283.     \the\@idxmaintoks
  284.     \ifx\temp\empty\else \idxsubentryseparator\the\@idxsubtoks \fi
  285.     \@idxrangestr
  286.   }%
  287.   %
  288.   % If this is a `see' or `see also' entry, we need to read one more
  289.   % arg.  We use a giant page number so the entry will be last (for the
  290.   % benefit of `see also's).  MakeIndex rejects page numbers >=1000.
  291.   % 
  292.   \if@idxsee
  293.     \@idxseefalse % Reset so the next term won't be a `see'.
  294.     \edef\temp{\noexpand\@finidxtokscollect{\idxmaxpagenum}}%
  295.   \else
  296.     \def\temp{\@finfinidxtokscollect\folio}%
  297.   \fi
  298.   \temp
  299. }%
  300. %
  301. %
  302. % \@finidxtokscollect{PAGENO}{REAL-TERM} reads the final term for
  303. % see/see also entries.  We do not check if the person has put both a
  304. % range and a see in the same index term (which will confuse makeindex).
  305. \def\@finidxtokscollect#1#2{%
  306.   \def\@idxseenterm{#2}%
  307.   \@finfinidxtokscollect{#1}%
  308. }%
  309. %
  310. % \@finfinidxtokscollect{PAGENO} writes \@indexentry for page PAGENO.
  311. % Besides \@indexentry, if \@idxpagemarkup is not \relax we output an
  312. % index entry \@indexentry|\@idxpagemarkup{PAGENO}.  And if
  313. % \@idxseenterm is not \relax we output {\@idxseenterm} after the
  314. % \@idxpagemarkup.  (This will become an argument to the ``markup''
  315. % command, which will be \indexsee or \indexseealso.)
  316. \def\@finfinidxtokscollect#1{%
  317.   % If we've got a page markup command, append it.
  318.   \ifx\@idxpagemarkup\relax \else
  319.     \toks@ = \expandafter{\@indexentry}%
  320.     \edef\@indexentry{\the\toks@ \idxencapoperator \@idxpagemarkup}%
  321.     \let\@idxpagemarkup = \relax
  322.   \fi
  323.   %
  324.   % If we've got an argument to the ``page markup'' command, append it.
  325.   \ifx\@idxseenterm\relax \else
  326.     \toks@ = \expandafter{\@indexentry}%
  327.     \edef\@indexentry{\the\toks@{\sanitize\@idxseenterm}}%
  328.     \let\@idxseenterm = \relax
  329.   \fi
  330.   %
  331.   % Finally, write what we've constructed.
  332.   \expandafter\@idxwrite\expandafter{\@indexentry}{#1}%
  333. }%
  334. %
  335. %
  336. % \@idxcollect{MAIN}{SUB} sets up the token registers
  337. % \@idx{main,sub}toks, then calls \@idxtokscollect.  This is convenient
  338. % for some of the macros below.
  339. \def\@idxcollect#1#2{%
  340.   \@idxmaintoks = {#1}%
  341.   \@idxsubtoks = {#2}%
  342.   \@idxtokscollect
  343. }%
  344. %
  345. %
  346. % Following are the TeX macros that correspond to the commands
  347. % that actually appear in the document.
  348. %
  349. % \@idx{TERM} produces TERM in the output and then makes the index entry
  350. % for TERM as usual.  We don't allow a [SUBTERM] here since then we
  351. % would lose spaces after the command, which would be very inconvenient.
  352. %
  353. % As with all our index commands, we've already defined \@idxprefix (in
  354. % \idx or whatever), to save passing it around, and we've looked for a
  355. % range argument before TERM.
  356. \def\@idx#1{%
  357.   #1% Produce TERM as output.
  358.   \@idxcollect{#1}{}%
  359. }%
  360. %
  361. % \@sidx{TERM}[SUBTERM] produces an index entry TERM and no output.  If
  362. % SUBTERM is present, this is a subentry.  (At the moment, I don't
  363. % provide for subsubentries, since I've never needed that.)
  364. \def\@sidx#1{\@idxmaintoks = {#1}\@getoptionalarg\@finsidx}%
  365. \def\@finsidx{%
  366.   \@idxsubtoks = \expandafter{\@optionalarg}%
  367.   \@idxtokscollect
  368. }%
  369. %
  370. %
  371. % \@idxconstructmarked{TOKS-REG}\CS{TERM}
  372. \def\idxsortkeysep{@}% This `@' is catcode 11, but it doesn't matter.
  373. %
  374. \def\@idxconstructmarked#1#2#3{%
  375.   \toks@ = {#2}% The control sequence.
  376.   \toks2 = {#3}% The term.
  377.   %
  378.   % Construct TERM@\CS{TERM} as the string to write.
  379.   \edef\temp{\the\toks2 \idxsortkeysep \the\toks@{\the\toks2}}%
  380.   %
  381.   % Save it in TOKS-REG.
  382.   #1 = \expandafter{\temp}%
  383. }%
  384. %
  385. %
  386. % \@idxmarked\CS{TERM} outputs \CS{TERM} and then calls the main part of
  387. % \@sidxmarked.
  388. %
  389. \def\@idxmarked#1#2{%
  390.   #1{#2}% Produce \CS{TERM} as output.
  391.   \@idxconstructmarked\@idxmaintoks{#1}{#2}%
  392.   \@idxsubtoks = {}%
  393.   \@idxtokscollect
  394. }%
  395. %
  396. % \@sidxmarked\CS{TERM}[SUBTERM] outputs an index entry sorted by TERM
  397. % but producing \CS{TERM}.
  398. \def\@sidxmarked#1#2{%
  399.   \@idxconstructmarked\toks@{#1}{#2}%
  400.   \edef\temp{{\the\toks@}}%
  401.   \expandafter\@sidx\temp
  402. }%
  403. %
  404. %
  405. % \@idxsubmarked{TERM}\CS{SUBTERM} is like \@idxmarked, except that it's
  406. % SUBTERM that's marked instead of TERM.
  407. \def\@idxsubmarked#1#2#3{%
  408.   #1 #2{#3}% produce `TERM \CS{SUBTERM} as output.
  409.   \@sidxsubmarked{#1}{#2}{#3}%
  410. }%
  411. %
  412. % \@sidxsubmarked{TERM}\CS{SUBTERM} is to \@sidxmarked as \@idxsubmarked
  413. % is to \@idxmarked.
  414. \def\@sidxsubmarked#1#2#3{%
  415.   \@idxmaintoks = {#1}%
  416.   \@idxconstructmarked\@idxsubtoks{#2}{#3}%
  417.   \@idxtokscollect
  418. }%
  419. %
  420. %
  421. % \@idxcollectname{FIRST}{LAST} puts `LAST, FIRST' into \temp. (Well,
  422. % we use \idxnameseparator instead of hardwiring `, '.) If FIRST is
  423. % empty, don't include the separator.
  424. \def\idxnameseparator{, }% as in `Tachikawa, Elizabeth'
  425. %
  426. \def\@idxcollectname#1#2{%
  427.   \def\temp{#1}%
  428.   \ifx\temp\empty
  429.     \toks@ = {}%
  430.   \else
  431.     \toks@ = {\idxnameseparator #1}%
  432.   \fi
  433.   \toks2 = {#2}%
  434.   %
  435.   \edef\temp{\the\toks2 \the\toks@}%
  436. }%
  437. %
  438. %
  439. % \@idxname{FIRST}{LAST} also produces `FIRST LAST' in the output and an
  440. % index entry for `LAST, FIRST'.
  441. %
  442. \def\@idxname#1#2{%
  443.   #1 #2% Separate the names by a space in the output.
  444.   \@idxcollectname{#1}{#2}%
  445.   \expandafter\@idxcollect\expandafter{\temp}{}%
  446. }%
  447. %
  448. % \@sidxname{FIRST}{LAST}[SUBTERM] is to \@sidx as \@idxname is to
  449. % \@idx.
  450. \def\@sidxname#1#2{%
  451.   \@idxcollectname{#1}{#2}%
  452.   \expandafter\@sidx\expandafter{\temp}%
  453. }%
  454. %
  455. %
  456. % Now we come to actually producing the index, i.e., implementing the
  457. % formatting commands that MakeIndex outputs.
  458. %
  459. % \readindexfile is responsible for formatting and printing the index.
  460. % It reads \indexfilebasename.ind.  We implement the same commands that
  461. % LaTeX does.  I suppose we could allow for different indices having
  462. % different basenames, but I can't imagine when that would be useful.
  463. \let\indexfonts = \relax
  464. \def\readindexfile#1{%
  465.   \edef\@idxprefix{#1}%
  466.   %
  467.   % Does the output file exist?
  468.   \testfileexistence[\indexfilebasename]{\@idxprefix nd}%
  469.   \iffileexists \begingroup
  470.     \indexfonts
  471.     %
  472.     % If no \begin or \end, define them. The argument will be `{theindex}'.
  473.     \ifx\begin\undefined
  474.       \def\begin##1{\@beginindex}%
  475.       \let\end = \@gobble
  476.     \fi
  477.     %
  478.     % Set up the default formatting:
  479.     \doublecolumns
  480.     \parindent = 0pt
  481.     %
  482.     % Let the user override the defaults.
  483.     \hookrun{beginindex}%
  484.     %
  485.     % Read the file:
  486.     \input \indexfilebasename.\@idxprefix nd
  487.     % 
  488.     % \doublecolumns isn't affected by groups.
  489.     \singlecolumn
  490.   \endgroup
  491.   \else
  492.     \message{No index file \indexfilebasename.\@idxprefix nd.}%
  493.   \fi
  494. }%
  495. %
  496. % Here's the default for `\begin{theindex}', if \begin isn't defined.
  497. \def\@beginindex{%
  498.   \let\item = \@indexitem
  499.   \let\subitem = \@indexsubitem
  500.   \let\subsubitem = \@indexsubsubitem
  501. }%
  502. %
  503. % \indexspace appears between groups in the ind file.
  504. \let\indexspace = \bigbreak
  505. %
  506. % You can make \afterindexterm appear after the term and before the
  507. % first page with the following in the ist file:
  508. % delim_0 "\\afterindexterm "
  509. % delim_1 "\\afterindexterm "
  510. % delim_2 "\\afterindexterm "
  511. \let\afterindexterm = \quad
  512. %
  513. %
  514. % Top-level index entries start with \item.
  515. \newskip\aboveindexitemskipamount  \aboveindexitemskipamount = 0pt plus2pt
  516. \def\aboveindexitemskip{\vskip\aboveindexitemskipamount}%
  517. %
  518. \def\@indexitem{\begingroup
  519.   \@indexitemsetup
  520.   \leftskip = 0pt
  521.   \aboveindexitemskip
  522.   \penalty-100 % Encourage page breaks before items.
  523.   % 
  524.   % But forbid page breaks after items, in case a subitem follows.
  525.   \def\par{\endgraf\endgroup\nobreak}%
  526. }%
  527. %
  528. % Secondary index entries.
  529. \def\@indexsubitem{%
  530.   \@indexitemsetup
  531.   \leftskip = 1em
  532. }%
  533. %
  534. % And tertiary entries.
  535. \def\@indexsubsubitem{%
  536.   \@indexitemsetup
  537.   \leftskip = 2em
  538. }%
  539. %
  540. % Common setup for the formatting.
  541. \def\@indexitemsetup{%
  542.   \par
  543.   \hangindent = 1em
  544.   \raggedright
  545.   \hyphenpenalty = 10000
  546.   \hookrun{indexitem}%
  547. }%
  548. %
  549. %
  550. % \indexsee{TERM}{PAGENO} ignores PAGENO, and says `See TERM'.
  551. \def\seevariant{\it}%
  552. \def\indexseeword{See}%
  553. \def\indexsee#1#2{{\seevariant \indexseeword\ }#1}%
  554. %
  555. % \indexseealso{TERM}{PAGENO} is similar.
  556. \def\indexseealsowords{see also}%
  557. \def\indexseealso#1#2{{\seevariant \indexseealsowords\ }#1}%
  558. %
  559. %
  560. % We provide one index by default; commands are \idx, \sidx, etc.
  561. \defineindex{i}%
  562. SHAR_EOF
  563. cat << \SHAR_EOF > idx.texi
  564. @node Indexing
  565. @section Indexing
  566.  
  567. @cindex indexing
  568. @cindex sorting an index
  569. @pindex makeindex
  570.  
  571. Eplain provides support for generating raw material for an index, and
  572. for typesetting a sorted index. A separate program must do the actual
  573. collection and sorting of terms, because @TeX{} itself has no support
  574. for sorting. Eplain's indexing commands work with the program MakeIndex,
  575. available by ftp from @samp{ftp.math.utah.edu} in
  576. @file{pub/tex/makeindex}, and from the CTAN hosts in
  577. @file{tex-archive/indexing/makeindex}; MakeIndex is also commonly
  578. included in prepackaged @TeX{} distributions.
  579.  
  580. The basic strategy for indexing works like this:
  581.  
  582. @enumerate
  583.  
  584. @pindex .idx @r{files}
  585. @item For a document @file{foo.tex}, Eplain's indexing commands (e.g.,
  586. @code{\idx}; see the section `Indexing terms' below) write the raw index
  587. material to @file{foo.idx}.
  588.  
  589. @pindex .ind @r{files}
  590. @item MakeIndex reads @file{foo.idx}, collects and sorts the index, and
  591. writes the result to @file{foo.ind}. 
  592.  
  593. @item Eplain reads and typesets @file{foo.ind} on the next run of @TeX{}.
  594.  
  595. @end enumerate
  596.  
  597. @cindex multiple indices
  598. @cindex indices, multiple
  599. @findex defineindex
  600. If your document needs more than one index, each must naturally have a
  601. separate file. Therefore, Eplain provides the command
  602. @code{\defineindex}, which takes an argument that is a single letter,
  603. which replaces @samp{i} in the filenames and in the indexing command
  604. names described below. For example,
  605.  
  606. @example
  607. \defineindex@{m@}
  608. @end example
  609.  
  610. @noindent will define the command @code{\mdx} to write to the file
  611. @file{foo.mdx}. Eplain simply does @code{\defineindex@{i@}} to define
  612. the default commands.
  613.  
  614. @menu
  615. * Indexing commands::        Specifying what to index.
  616. * MakeIndex interaction::    MakeIndex conventions followed by Eplain.
  617. * Typesetting an index::    Printing the sorted output.
  618. @end menu
  619.  
  620.  
  621. @node Indexing commands
  622. @subsection Indexing commands
  623.  
  624. @cindex indexing terms
  625. @cindex indexing
  626.  
  627. \idx{term}
  628. \sidx{term}[subterm]
  629. \idxmarked\defn{term}
  630. \sidxmarked\defn{term}[subterm]
  631. \idxsubmarked{term}\defn{subterm}
  632. \sidxsubmarked{term}\defn{subterm}
  633. \idxname{First}{Last}
  634. \sidxname{First}{Last}[subterm]
  635. \idxnameseparator
  636.  
  637. \extraidxcmdsuffixes
  638.  
  639. \hookaction{afterindexterm}
  640.  
  641. \idxbeginrangemark [begin] -> (
  642. \idxendrangemark [end]   -> )
  643. \indexseeword [see]
  644. \indexseealsoword [seealso]
  645. [pagemarkup=defn]
  646.  
  647. \idx{Ap-weight@$A_p$-weight}
  648.  
  649. @menu
  650. * Proofing index terms::    Noting index entries where they're made.
  651. @end menu
  652.  
  653.  
  654. @node
  655. @subsubsection Proofing index terms
  656.  
  657. \indexproofing{true,false}
  658.   \indexsetmargins
  659.     \outsidemargin
  660.     \insidemargin
  661.   \indexproofunbox
  662.  
  663.  
  664. @node
  665. @subsection MakeIndex interaction
  666.  
  667. \idxsubentryseparator
  668. \idxencapoperator
  669. \idxmaxpagenum
  670.  
  671. \afterindexterm
  672.  
  673. \item
  674. \subitem
  675. \subsubitem
  676.  
  677.  
  678. @node Typesetting an index
  679. @subsection Typesetting an index
  680.  
  681. \readindexfile{i}
  682.   \indexfilebasename
  683.   \indexfonts
  684.   \begin{theindex}...\end{theindex}
  685.   \hookaction{beginindex}
  686.   
  687.   \aboveindexitemskip{,amount}
  688.   \hookaction{indexitem}
  689.   \indexspace
  690. SHAR_EOF
  691. #    End of shell archive
  692. exit 0